package org.fin.framework.ioc.util;

import org.fin.framework.ioc.factory.AbstractApplicationContext;

/**
 * 用于获取Bean
 */
public class ApplicationContextUtils {

  private static AbstractApplicationContext applicationContext;

  private ApplicationContextUtils(){}

  public static AbstractApplicationContext getApplicationContext() {
    return applicationContext;
  }

  public static void setApplicationContext(AbstractApplicationContext applicationContext) {
    ApplicationContextUtils.applicationContext = applicationContext;
  }

  public static Object getBean(String id) {
    return applicationContext.getBean(id);
  }

  public static <T> T getBean(String id, Class<T> type) {
    return applicationContext.getBean(id, type);
  }

  public static <T> T getBean(Class<T> type) {
    return applicationContext.getBean(type);
  }
}
